+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+                                                                                                                     +
+    Resource 1.01                                                                                                    +
+    By Johan Rydh                                                                                                    +
+    <jrydh@hotmail.com> (please set the subject to Resource 1.01)                                                    +
+                                                                                                                     +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

RESOURCE is a routine that copies a program from Archive or RAM to the program TEMP# (in RAM; # could be 0 - 9).
It means that you can run program in Archive (or in RAM) without unarchive them by yourself!
It detects if the program is a basic- or an asm-program.

TI Freak Ware has made a rewritten version of this ReadMe that could be easier to understand.
To view it open the included shortcut, or visit:
 http://tifreakware.calcgames.org/resource.htm

Text between [ ] can you include if you want, not needed. (Don't include the [ ] tokens)
Text between < > tells you what you should write INSTEAD. (Don't include the < > tokens)
-> means the Sto(re) token.

(A bug is fixed in this version that could cause an OS error message. It should now work.)



INFORMATION FOR USERS:
======================

When you start a program in the TI-OS (home screen), use this syntax:

"<Resource to load>":prgmLDSOURCE

Recommended key presses:
PRGM, choose a program to run		set the program name
Up, ALPHA, + (" token)			go to the prgm-token and replace it with "
Down, ALPHA, + (" token)		go to the end of the entry and set the last "
ALPHA, . (: token)			set the :
2nd, CATALOG, choose Asm(		set Asm(
PRGM, choose LDSOURCE			set prgmLDSOURCE
ENTER					Execute the instructions

This will erase all temp programs, then create and run, TEMP0 and TEMP, (This means run the "Resource to load")
finally remove all temp programs and STOP (not return).
NO ARGUMENT VIA THE ANS VARIABLE COULD BE SENT TO THE RESOURCE THAT YOU LOAD!

THIS SYNTAX SHOULD NOT BE USED IN A PROGRAM!

Please read the IMPORTANT part below too!



INFORMATION FOR PROGRAMMERS AND DEVELOPERS:
===========================================

LDSOURCE is a TI-Basic prgm that handles errors when loading resources (LoaD reSOURCE).
RESOURCE is an Asm prgm that executes the commands.
It's recommended to use LDSOURCE when you are loading a resource.

COMMANDS:

 "<Resource to load>":Asm(prgmRESOURCE
	Erases first all the temp prgms (TEMP, TEMP0-TEMP9)
	Loads then the resource, this creates prgmTEMP0
	If successful: prgmTEMP is created as link to prgmTEMP0, Ans will hold the value 2.
		       The content of prgmTEMP will be  :prgmTEMP0  or  :Asm(prgmTEMP0
	Else prgmTEMP will not be created and Ans will hold 0 (zero)
			
 This command is not recommend to use, use the following command instead.


 "<Resource to load and run>":prgmLDSOURCE
	First it does the same as the previous routine, but will show an error message if not successful.
	If successful the prgmTEMP (that was created) will be run.
	Then (both if successful and not successful) all temp prgms (TEMP, TEMP0-TEMP9) will be erased,
	at last the program flow is stopped by the TI-Basic command Stop.

 This command is recommend to run programs in Archive from home screen, not in programs.


 "0<Resource to load>":Asm(prgmRESOURCE
	This will load the resource, and create one of the prgms TEMP1-TEMP9 (not TEMP0), and erase prgmTEMP.
	If none of the prgms exist TEMP1 will be created, if TEMP2 doesn't exist then TEMP2 will be created, and so on.
	If prgmTEMP9 already exists an error occurs and Ans will hold -1.
	If any other error occurs Ans will hold 0.
	If successful prgmTEMP is created as a link to prgmTEMPx that was created, Ans will hold 1.

 It's recommend to use the following command instead, which will handle any errors.


 "0<Resource to load>":prgmLDSOURCE
	Does the same as the previous routine, but will show an
	error message and stop the program flow if not successful.

 This command is recommend to use in programs.


 "":Asm(prgmRESOURCE
	Will erase all temp programs (TEMP, TEMP0-TEMP9)

 This command is not recommend to use in programs, use the following command instead.


 "0":Asm(prgmRESOURCE
	This will erase the temp program with the highest number, then update prgmTEMP as a link
	to the program that now has the highest number. prgmTEMP will be erased if prgmTEMP1
	doesn't exist. (This could not link prgmTEMP to prgmTEMP0)

 Use this command in programs instead of the previous, you may use a loop construction. (see below)


NOTE: prgmTEMP is a link to the prgmTEMPx with highest number (x), and will be updated (erased when an error occurs)
      at every command. prgmTEMP includes the Asm( command if prgmTEMPx is an Asm prgm. Don't try to run Asm(prgmTEMP

      Commands other than described will not be working ("" or "0" before prgmLDSOURCE will result into an OS error)

      If you load a protected program prgmTEMPx will be protected, else it will not be protected.
      When you are testing your program it could be good that the program isn't protected, so you can see
      where an error occurs.
      A VERY COMMON PROBLEM is that you may EDIT THE TEMPx PROGRAM, then the CHANGES WILL BE OVERWRITTEN
      the next time you start your program. Remember this, else you may waste a lot of time.


You can always (an exceptions: on error) run prgmTEMP to run the temp program with the highest number.
If you will run another already loaded program you can run it using  :prgmTEMP<x>  or  :Asm(prgmTEMP<x>
but if you are using this code you have to know what number the program you should run has, and you
have to remove any temp program in the beginning of your program, see the code example below.
Else you can remove the resources that have a higher number and then run prgmTEMP.

:For(<VARIABLE>,1,9)		Erases up to all the 9 temp programs, you can use any variable
:"0"				Place this code first in your main program
:Asm(prgmRESOURCE
:End

This code is recommend to include in the beginning of the main program, to remove any existing temp program.
It can also be used at the end of your main program to erase all the loaded resources (or some of them),
you can the change the interval to 1,x where x is how many temp program to erase.
(This will erase the temp programs from the top to the bottom, you can't erase TEMP1 before TEMP2, and so on)
No error will be returned if the command failed, Ans will not hold any status info.
(This command can't erase prgmTEMP0)

To load a resource, use the following syntax:

:"0<Resource to load>"
:prgmLDSOURCE

When you then run the loaded program, use one of these syntaxes:

:prgmTEMP		Runs the latest loaded program (TI-Basic or Asm)
  or
:[Asm(]prgmTEMP<x>	Runs the program loaded as number x.

Finally you need to erase the (latest loaded) temp program:

:"0"			You can place this code in a loop construction if you want to erase more than one temp program
:Asm(prgmRESOURCE											   (see above)


You could load subroutines from a subroutine, but remember that there could not be more than nine
temporary programs. It means that you could not load a subroutine from a subroutine to many times
(without to exit the subroutine(s) and remove the temporary program).


You could either load every program when you should run it, and afterwards remove it,
or you could load all programs in the beginning of the program and run them later.
I recommend a mixture of these two methods, load and remove programs often will slow
down your program a little (every command take some time...), but to have all programs
loaded at the same time requires a lot of free RAM memory. Programs that often are running
could be loaded in the beginning, and programs that just are running once or twice may
be loaded when they should run.


IMPORTANT! (To avoid conflicts between different programs and users)
===================================================================

 For users: (For best use/functionality)
 ---------------------------------------
  + Use the syntax for loading a program from the home screen, that will erase any temp programs (if any exist),
    and will not cause any program to overuse the temp program-places, and will finally erase all temp programs.
  + Be sure that there are enough free RAM and that all sub-routines exist, else the program may break.
  + Be sure that both program RESOURCE and LDSOURCE are in RAM!
  + If the OS returns an error (not the built in error message (Resource)) you may need to erase the temporary
    programs (prgmTEMP, prgmTEMP0 - prgmTEMP9). Use either the memory menu, or this command: "":Asm(prgmRESOURCE)

 For programmers: (Please read this to avoid problems in your programs)
 ----------------------------------------------------------------------
  + In a program, NEVER use the syntax for loading a routine from TI-OS/Home screen (the one without a zero),
    that could cause some errors if the user load your program with that routine.
  + You can use up to nine temporary program-places.
  + Do not forget to remove any existing temporary program in the beginning of your program, and don't forget to erase
    all temporary programs before your program ends, to free up memory.
  + It is recommend to write out how much free RAM, which is needed to run the program without any memory error.
    (Remember that the asm program RESOURCE takes around 500 bytes when it is running.)
  + If there is not enough memory to load a resource or if another error occurs, the basic program LDSOURCE shows an
    error message and then STOPS the program flow (using command Stop), YOUR PROGRAM DOES NOT NEED TO CHECK FOR ERRORS!
  + Please read all the information carefully for best use and to avoid problems.


  + DO NOT MODIFY THIS SOFTWARE, IT MAY CAUSE ERRORS IF THE USER RUNS ANOTHER PROGRAM THAT USES THIS SOFTWARE!

    If you want to change the basic program LDSOURCE, it's recommended to include the changed code IN YOUR PROGRAM
    IF YOU INCLUDE A MODIFIED VERSION OF LDSOURCE IN YOUR PROGRAM, DO NOT FORGET TO INCLUDE THE ORIGINAL PROGRAM!
    (To translate the program LdSource into another language is all right,
     BUT USE THE SAME NAME, LdSource on calc, the computer filename may be added with the language,
     AND DON'T FORGET TO INCLUDE THE ENGLISH VERSION TOO!)
    If you have translated LdSource into another language and are sure that there aren't any spelling errors,
    you can feel free to send it to me if you want, and I will include it in Resource and give you a credit.

  + PLEASE GIVE ME A CREDIT IF YOU ARE USING THIS SOFTWARE, AND INCLUDE THIS DOCUMENT!

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+                                                                                                                     +
+    IF YOU HAVE ANY QUESTIONS OR IDEAS, PLEASE MAIL ME AT jrydh@hotmail.com (please set the subject to Resource)     +
+                                                                                                                     +
+    Resource 1.01                                                                                                    +
+    By Johan Rydh                                                                                                    +
+    <jrydh@hotmail.com> (please set the subject to Resource 1.01)                                                    +
+                                                                                                                     +
+    English and Swedish versions of the program LDSOURCE are included.                                               +
+                                                                                                                     +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

THANKS TO:
----------

Jimmy Nordstrm who has given me some very useful ideas, and who has also has tested the software,
		and he has also discovered the bug fixed in this version.
Sean McLaughlin for the "Learn TI-83 Plus Assembly In 28 Days"-guide, where I have learnt much about
		assembly programming.
